package com.ct.blog.pojo.response;

import com.ct.blog.common.constant.Constants;
import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String errMsg;
    private T data;

    public static <T> Result success (T data) {
        Result result = new Result();
        result.setCode(Constants.RESULT_SUCCESS);
        result.setData(data);
        return result;
    }

    public static <T> Result fail (String errMsg) {
        Result result = new Result();
        result.setCode(Constants.RESULT_FAIL);
        result.setErrMsg(errMsg);
        return result;
    }

    public static <T> Result fail (String errMsg, T data) {
        Result result = new Result();
        result.setCode(Constants.RESULT_FAIL);
        result.setErrMsg(errMsg);
        result.setData(data);
        return result;
    }
}
